<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.Config,cn.edu.nju.ws.sview.util.URIUtil,java.net.URLEncoder,cn.edu.nju.ws.sview.util.URIUtil,java.util.Enumeration,cn.edu.nju.ws.sview.views.Entity,java.util.HashMap,java.util.HashSet,java.util.ArrayList,java.util.Map.Entry,cn.edu.nju.ws.sview.cache.*" %>
<%@page import="cn.edu.nju.ws.sview.views.Group,cn.edu.nju.ws.sview.views.DataMember,cn.edu.nju.ws.sview.views.URIDataMember,cn.edu.nju.ws.sview.views.View" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SView editing</title>
<link rel="icon" href="/sview/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/views/evedit.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/smoothness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
<script type="text/javascript" src="/sview/script/views/evedit.js"></script>
</head>
<body>
<%
	String lang = request.getParameter("lang");
if(lang!=null &&lang.equals("zh")){
	request.getRequestDispatcher("evedit_zh.jsp").forward(request,response);
	return;
}else if(lang==null){
	lang="en" ;
}
String genre = request.getParameter("genre");
String eidStr =  request.getParameter("eid");

int eid =0;
int etype=0;
String gname = (String)session.getAttribute("groupName");
if(genre==null||gname==null){
	String location = "../views/index.jsp";
	if(lang.equals("zh"))
		location = location+"?lang="+lang;
	response.sendRedirect(location);
	return;
}else{
	eid = Integer.parseInt(eidStr);
}
if(genre.equals(Entity.URI_ENTITY_Str))
	etype = Entity.URI_ENTITY;
else if(genre.equals(Entity.CUSTOM_ENTITY_Str))
		etype = Entity.CUSTOM_ENTITY;
else if(genre.equals(Entity.COLLECTION_Str))
	etype = Entity.COLLECTION;

/*view id >0 means enter from edit point*/
String vidStr = request.getParameter("vid");
int vid = 0;
if(vidStr!=null){
	vid = Integer.parseInt(vidStr) ;
}

int gid = Group.getGroupIdByName(gname);

String isInnerStr = request.getParameter("i");
int isInner = Integer.parseInt(isInnerStr);
String cidStr = request.getParameter("cid");
int cid = Integer.parseInt(cidStr) ;
String from = request.getParameter("f");
%>
<jsp:include page="/vheader.jsp" flush="true">
   <jsp:param name="f" value="e"/>
</jsp:include>
<div class="container">
   <div class="top">
     <div class="operation"> Construct a new view </div>
     <div class="edit-save"> 
     <input type="button" value="Save" class="sbutton btn btn-primary fb">
     <input type="button" value="Cancel" class="cbutton btn fb">
     </div>
   </div>
   <div class="mspacingLittle"></div>
   <div class="main">
	   <div class="mspacing"></div>
		<div>
			<span class="mtitle">Name</span>&nbsp;
			<% if(vid>0){
				View view = View.getViewByViewId(vid);
				String name = view.getName();
			%>
			<input type="text" name="queryName" value ="<%=name%>" class="ftext" />
		    <%
			    }else{
		    %>
		    <input type="text" name="queryName"  class="ftext" />
		    <%
			    }
		    %>
		</div>
		<div class="mspacing"></div>
		<div class="mspacingLittle"></div>
		<div class="panel">
		 <div class="leftPanel">
		   <div class='hintTitle'>
		   Query Items
		    <span class='opHint'><span class="opStrong">Hint:</span> Add query item from Available Query Items<a class='closeHint'></a></span>
		   </div>
		   <div class="vcontent" >
	        </div>
	     </div>
	     <div class="rightPanel">
		    <div class="vnav">
		       <div class="dtitle">
				  <span class="nav-title">Available Query Items</span>
				  <div class="dmcreate-box"><a class="easyui-linkbutton dm_create" title="Create a new query item" plain="true" iconCls="icon-dm_create">New</a></div>
			   </div>
			   <div class="search_tool">
			        <div class="myac-box qitem-box-inview">
		  	   			<div class="searchNote">Search a query item</div>
	           			<input class="myac-input dmsearch" type="text">
		    		</div>
		    		<div class ="searchBox"><ul id='vsresult' class='vsresult'></ul></div>
		      </div>
		      <div id="dms">
		        <ul class="dmList" >
		           <span class='hint_gray'>Try to search a query item and find its values</span>
		        </ul>			   
			 </div>					 	 	  
	         </div>
	       </div>
		</div>
	</div>
</div>
<input type='hidden'  id="display-lang" value="en"/>
<input type='hidden'  id="count" value="0" />
<input type='hidden' id="etype" value=<%=etype %> />
<input type='hidden' id="genre" value=<%=genre %> />
<input type='hidden'  id="eid" value=<%=eid %> />
<input type='hidden' id="vlayout" value=1 />
<input type='hidden'  id="vid" value=<%=vid%> />
<input type='hidden'  id="gid" value=<%=gid%> />
<input type='hidden'  id="isInner" value=<%=isInner%> />
<input type='hidden'  id="cid" value=<%=cid%> />
<%if(from!=null){ %>
<input type='hidden'  id="from" value=<%=from%> />
<% }%>
<jsp:include page="/vfooter.jsp"></jsp:include>
</body>
</html>